package com.Prot2.Logger;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.BatteryManager;

public class BatteryWorker {
	
	private int BatteryLevel;

	private BroadcastReceiver mBatteryInfoReceiver = new BroadcastReceiver(){
		@Override
		public void onReceive(Context context, Intent intent) {
			BatteryLevel = intent.getIntExtra(BatteryManager.EXTRA_LEVEL, 0);
		}	
	};
	
	public BatteryWorker(Context c){
		
		c.registerReceiver(mBatteryInfoReceiver, new IntentFilter(Intent.ACTION_BATTERY_CHANGED));
	}
	
	public int getBatteryLevel(){
		return BatteryLevel;
	}

	public String getRead(String DELIMITER){
		return ""+BatteryLevel;
	}
	
	public void stop(Context c){
		c.unregisterReceiver(mBatteryInfoReceiver);
	}
	
}
